/**
 * Created by ruiyuan on 15-9-22.
 */
'use strict';


angular.module('marketFilters', [])
    .filter('dateFormat', function () {
        return function (input) {

            var d = new Date(input), now = new Date(),
                dStamp = d.getTime(), nowStamp = now.getTime();
            if (now.getFullYear() - d.getFullYear() > 0) {
                return d.getFullYear() + "年" + (d.getMonth() + 1) + "月" + d.getDate() + '日';
            } else if ((nowStamp - dStamp) / 1000 < 60) {
                return "刚刚";
            } else if ((nowStamp - dStamp) / 60000 < 60) {
                return Math.floor((nowStamp - dStamp) / 60000) + "分钟前";
            } else if ((nowStamp - dStamp) / 3600000 < 24) {
                return Math.floor((nowStamp - dStamp) / 3600000) + "小时前";
            } else if ((nowStamp - dStamp) / 86400000 >= 1 && (nowStamp - dStamp) / 86400000 <= 3) {
                return Math.floor((nowStamp - dStamp) / 86400000) + "天前";
            } else if ((nowStamp - dStamp) / 86400000 > 3) {
                return (d.getMonth() + 1) + "月" + d.getDate() + "日";
            }
        };
    });
